package com.mmy.fta.cargo.web.rest;

import com.mmy.fta.cargo.server.dto.DayPredictCargoDTO;
import com.mmy.fta.cargo.server.dto.WeekPredictCargoDTO;
import com.mmy.fta.cargo.server.service.CargoPredictService;
import com.mmy.fta.cargo.web.enums.DefaultResponseCode;
import com.mmy.fta.cargo.web.request.CargoPredictWebRequest;
import com.mmy.fta.cargo.web.request.PublishCargoRequest;
import com.mmy.fta.cargo.web.response.PredictCargoResponse;
import com.mmy.fta.cargo.web.response.PublishCargoResponse;
import com.ymm.common.rpc.YmmResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Slf4j
@RestController
@RequestMapping(value = "/predict")
public class CargoPredictController {

    @Autowired
    CargoPredictService cargoPredictService;

    /**
     * 预测
     */
    @PostMapping(value = "predictCargo")
    public PredictCargoResponse getCargoPredictHour(@RequestBody CargoPredictWebRequest cargoPredictWebRequest) {
        PredictCargoResponse predictCargoResponse=new PredictCargoResponse();
        //List<Integer> cargoHour = new ArrayList();
        DayPredictCargoDTO dayPredictCargoDTO = cargoPredictService.predictDayCargoNumber(cargoPredictWebRequest.getStartCity(), cargoPredictWebRequest.getEndCity());
        predictCargoResponse.setDayPredictCargo(dayPredictCargoDTO);

        WeekPredictCargoDTO weekPredictCargoDTO = cargoPredictService.predictWeekCargoNumber(cargoPredictWebRequest.getStartCity(), cargoPredictWebRequest.getEndCity());
        predictCargoResponse.setWeekPredictCargo(weekPredictCargoDTO);

        //log.info("返回每小时发货量预测：{}",cargoHour);
        return predictCargoResponse;
    }
}
